/*
 * Copyright (c) 2009 Roman Savelyev
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * THE SOFTWARE.
 */

#ifndef __CONUIENGINE_H__
#define __CONUIENGINE_H__

#include "conuidef.h"
#include <e32base.h>
#include <e32twin.h>

class CDrawingBuffer;

class MConUiEngineObserver
    {
public:
    virtual void HandleEngineError(TInt aError) = 0;
    };

class CConUiEngine : public CBase
    {
public:
    IMPORT_C static CConUiEngine* NewL(const TSize& aSize);
    IMPORT_C static CConUiEngine* NewL(const TDesC8& aTerminalType);
    IMPORT_C ~CConUiEngine();
    IMPORT_C MConUiEngineObserver* Observer();
    IMPORT_C void PushObserverL(MConUiEngineObserver& aObserver);
    IMPORT_C void PopObserver(const MConUiEngineObserver* aCheckItem=NULL);
    IMPORT_C TBool CursorVisible() const;
    IMPORT_C void SetCursorVisible(TBool aVisible);
    virtual TSize SurfaceSize() = 0;
    virtual void ClearSurface() = 0;
    virtual TPoint CursorPos() const = 0;
    virtual void SetCursorPos(const TPoint& aPos) = 0;
    virtual void ReadKey(TConsoleKey& aKey, TRequestStatus& aStatus) = 0;
    virtual void ReadKeyCancel() = 0;
    virtual void DrawRegionL(const CDrawingBuffer& aBuffer, const RRegion& aRegion) = 0;
protected:
    IMPORT_C CConUiEngine();
    virtual void DoSetCursorVisible(TBool aVisible) = 0;
private:
    RPointerArray<MConUiEngineObserver> iObserverStack;
    TBool iCursorVisible;
    };

#endif /* __CONUIENGINE_H__ */
